import { axios } from "./axios";
import Notify from '../miniprogram_npm/@vant/weapp/notify/notify';
import Toast from '../miniprogram_npm/@vant/weapp/toast/toast';
//-----------------------USER-----------------------
// 实名认证
export const updateAddress = async (parms: any) => {
  try {
    let obj: RequestInterface = {
      url: "/api/users/updateAddress",
      method: "POST",
      data: parms
    }
    const data = await axios(obj);
    return data;
  } catch (err) {
    // @ts-ignore
    Toast.fail(err.msg);
  }
}
// 实名认证
export const updateUserInfo = async (parms: any) => {
  try {
    let obj: RequestInterface = {
      url: "/api/users/updateUserInfo",
      method: "POST",
      data: parms
    }
    const data = await axios(obj);
    return data;
  } catch (err) {
    // @ts-ignore
    Toast.fail(err.msg);
  }
}
// 实名认证
export const realNameAuth = async (parms: any) => {
  try {
    let obj: RequestInterface = {
      url: "/api/users/realNameAuth",
      method: "POST",
      data: parms
    }
    const data = await axios(obj);
    return data;
  } catch (err) {
    Toast.fail(err.msg);
  }
}
// 登录
export const getUserInfo = async (parms: any) => {
  try {
    let obj: RequestInterface = {
      url: "/api/users/login-pwd",
      method: "GET",
      data: parms
    }
    const data = await axios(obj);
    return data;
  } catch (err) {
    Toast.fail(err.msg);
  }
}
// 注册
export const setUser = async (parms: any) => {
  try {
    let obj: RequestInterface = {
      url: "/api/users/registered",
      method: "POST",
      data: parms
    }
    const data = await axios(obj);
    return data;
  } catch (err) {
    Toast.fail(err.msg);
  }
}
// 免密登录
export const avoidPwdLogin = async () => {
  try {
    let obj: RequestInterface = {
      url: "/api/users/avoidPwdLogin",
      method: "GET"
    }
    const { data } = await axios(obj);
    return data;
  } catch (error) {
    Notify({
      message: `${error.msg}`,
      duration: 5000,
      selector: '#custom-selector',
    });
  }
}
//-----------------------BLOG-----------------------
// 点赞留言
export const leaveWordUnlike = async (params: any) => {
  try {
    let obj: RequestInterface = {
      url: "/api/blog/leaveWordUnlike",
      method: "POST",
      data: params
    }
    const { data } = await axios(obj);
    return data;
  } catch (err) {
    // @ts-ignore
    Toast.fail(err.msg);
  }
}
// 点赞留言
export const leaveWordlike = async (params: any) => {
  try {
    let obj: RequestInterface = {
      url: "/api/blog/leaveWordlike",
      method: "POST",
      data: params
    }
    const { data } = await axios(obj);
    return data;
  } catch (err) {
    Toast.fail(err.msg);
  }
}
// 删除
export const deleteBlog = async (params: any) => {
  try {
    let obj: RequestInterface = {
      url: "/api/blog/deleteBlog",
      method: "POST",
      data: params
    }
    const { data } = await axios(obj);
    return data;
  } catch (err) {
    Toast.fail(err.msg);
  }
}
// 我新欢
export const getMyCollectionBlog = async (params: any) => {
  try {
    let obj: RequestInterface = {
      url: "/api/blog/getMyCollectionBlog",
      method: "GET",
      data: params
    }
    const { data } = await axios(obj);
    return data;
  } catch (err) {
    Toast.fail(err.msg);
  }
}
// 我新欢
export const getMyLikeBlog = async (params: any) => {
  try {
    let obj: RequestInterface = {
      url: "/api/blog/getMyLikeBlog",
      method: "GET",
      data: params
    }
    const { data } = await axios(obj);
    return data;
  } catch (err) {
    Toast.fail(err.msg);
  }
}
// 添加博文
export const getMyUploadBlog = async (params: any) => {
  try {
    let obj: RequestInterface = {
      url: "/api/blog/getMyUploadBlog",
      method: "GET",
      data: params
    }
    const { data } = await axios(obj);
    return data;
  } catch (err) {
    Toast.fail(err.msg);
  }
}
// 添加博文
export const getBookingBlog = async (params: any) => {
  try {
    let obj: RequestInterface = {
      url: "/api/blog/getBookingBlog",
      method: "GET",
      data: params
    }
    const { data } = await axios(obj);
    return data;
  } catch (err) {
    Toast.fail(err.msg);
  }
}
// 添加博文
export const getSameHair = async (params: any) => {
  try {
    let obj: RequestInterface = {
      url: "/api/blog/getSameHair",
      method: "GET",
      data: params
    }
    const { data } = await axios(obj);
    return data;
  } catch (err) {
    Toast.fail(err.msg);
  }
}
// 添加博文
export const addBlog = async (params: any) => {
  try {
    let obj: RequestInterface = {
      url: "/api/blog/addBlog",
      method: "POST",
      data: params
    }
    const { data } = await axios(obj);
    return data;
  } catch (err) {
    Toast.fail(err.msg);
  }
}
// 查询博文
export const getBlog = async (params: any) => {
  try {
    let obj: RequestInterface = {
      url: "/api/blog/getBlog",
      method: "GET",
      data: params
    }
    const { data } = await axios(obj);
    return data;
  } catch (err) {
    Toast.fail(err.msg);
  }
}
// 查询详细博文
export const getBlogDetails = async (params: any) => {
  try {
    let obj: RequestInterface = {
      url: "/api/blog/getBlogDetails",
      method: "GET",
      data: params
    }
    const { data } = await axios(obj);
    return data;
  } catch (err) {
    Toast.fail(err.msg);
  }
}
// 点击量记录
export const setSeeNumber = async (params: any) => {
  try {
    let obj: RequestInterface = {
      url: "/api/blog/setSeeNumber",
      method: "POST",
      data: params
    }
    const { data } = await axios(obj);
    return data;
  } catch (err) {
    Toast.fail(err.msg);
  }
}
// 点赞
export const setLikeBlog = async (params: any) => {
  try {
    let obj: RequestInterface = {
      url: "/api/blog/setLikeBlog",
      method: "POST",
      data: params
    }
    const data = await axios(obj);
    return data;
  } catch (err) {
    Toast.fail(err.msg);
  }
}
// UN点赞
export const setUnLikeBlog = async (params: any) => {
  try {
    let obj: RequestInterface = {
      url: "/api/blog/setUnLikeBlog",
      method: "POST",
      data: params
    }
    const data = await axios(obj);
    return data;
  } catch (err) {
    Toast.fail(err.msg);
  }
}
// 收藏
export const setCollectionBlog = async (params: any) => {
  try {
    let obj: RequestInterface = {
      url: "/api/blog/setCollectionBlog",
      method: "POST",
      data: params
    }
    const data = await axios(obj);
    return data;
  } catch (err) {
    Toast.fail(err.msg);
  }
}
// 取消收藏
export const setUnCollectionBlog = async (params: any) => {
  try {
    let obj: RequestInterface = {
      url: "/api/blog/setUnCollection",
      method: "POST",
      data: params
    }
    const data = await axios(obj);
    return data;
  } catch (err) {
    Toast.fail(err.msg);
  }
}
// 发表留言
export const setLeaveWordBlog = async (params: any) => {
  try {
    let obj: RequestInterface = {
      url: "/api/blog/setLeaveWord",
      method: "POST",
      data: params
    }
    const data = await axios(obj);
    return data;
  } catch (err) {
    Toast.fail(err.msg);
  }
}
// 获取留言
export const getLeaveWordBlog = async (params: any) => {
  try {
    let obj: RequestInterface = {
      url: "/api/blog/getLeaveWord",
      method: "GET",
      data: params
    }
    const { data } = await axios(obj);
    return data;
  } catch (err) {
    Toast.fail(err.msg);
  }
}
//-----------------------SHOP-----------------------
export const getOrderLeaveWord = async (params: any) => {
  try {
    let obj: RequestInterface = {
      url: "/api/shop/getOrderLeaveWord",
      method: "GET",
      data: params
    }
    const data = await axios(obj);
    return data;
  } catch (err) {
    Toast.fail(err.msg);
  }
}
// 获取店铺下的发型师
export const orderLeaveWord = async (params: any) => {
  try {
    let obj: RequestInterface = {
      url: "/api/shop/orderLeaveWord",
      method: "POST",
      data: params
    }
    const data = await axios(obj);
    return data;
  } catch (err) {
    Toast.fail(err.msg);
  }
}
// 获取店铺下的发型师
export const getHairstylist = async (params: any) => {
  try {
    let obj: RequestInterface = {
      url: "/api/shop/getShopHairstylist",
      method: "GET",
      data: params
    }
    const data = await axios(obj);
    return data;
  } catch (err) {
    Toast.fail(err.msg);
  }
}
// 获取指定发型师数据
export const getHairstylistInfo = async (params: any) => {
  try {
    let obj: RequestInterface = {
      url: "/api/shop/getHairstylist",
      method: "GET",
      data: params
    }
    const data = await axios(obj);
    return data;
  } catch (err) {
    Toast.fail(err.msg);
  }
}
export const createShop = async (params: any) => {
  // registerShop
  try {
    let obj: RequestInterface = {
      url: "/api/shop/registerShop",
      method: "POST",
      data: params
    }
    const data = await axios(obj);
    return data;
  } catch (err) {
    Toast.fail(err.msg);
  }
}
// 查看有无申请状态
export const shopState = async () => {
  try {
    let obj: RequestInterface = {
      url: "/api/shop/userAShopState",
      method: "GET"
    }
    const data = await axios(obj);
    return data;
  } catch (err) {
    // @ts-ignore
    Toast.fail(err.msg);
  }
}
// 查询店铺的列表
export const getShopList = async (params: any) => {
  try {
    let obj: RequestInterface = {
      url: "/api/shop/getShopList",
      method: "GET",
      data: params
    }
    const data = await axios(obj);
    return data;
  } catch (err) {
    Toast.fail(err.msg);
  }
}
// 查询店铺的详情
export const getShopDetails = async (params: any) => {
  try {
    let obj: RequestInterface = {
      url: "/api/shop/getShopDetails",
      method: "GET",
      data: params
    }
    const data = await axios(obj);
    return data;
  } catch (err) {
    Toast.fail(err.msg);
  }
}
// 发型师项目
export const getServiceItems = async (params: any) => {
  try {
    let obj: RequestInterface = {
      url: "/api/shop/getServiceItems",
      method: "GET",
      data: params
    }
    const data = await axios(obj);
    return data;
  } catch (err) {
    Toast.fail(err.msg);
  }
}
// 发型师项目
export const getSubscribeDetails = async (params: any) => {
  try {
    let obj: RequestInterface = {
      url: "/api/shop/getSubscribeDetails",
      method: "GET",
      data: params
    }
    const data = await axios(obj);
    return data;
  } catch (err) {
    Toast.fail(err.msg);
  }
}
// 生成订单
export const setBookingOrder = async (params: any) => {
  try {
    let obj: RequestInterface = {
      url: "/api/shop/setBookingOrder",
      method: "POST",
      data: params
    }
    const data = await axios(obj);
    return data;
  } catch (err) {
    Toast.fail(err.msg);
  }
}
// 生成订单
export const getBookingOrder = async (params: any) => {
  try {
    let obj: RequestInterface = {
      url: "/api/shop/getBookingOrder",
      method: "GET",
      data: params
    }
    const data = await axios(obj);
    return data;
  } catch (err) {
    Toast.fail(err.msg);
  }
}
// 生成订单
export const getAllOrder = async (params: any) => {
  try {
    let obj: RequestInterface = {
      url: "/api/shop/getAllOrder",
      method: "GET",
      data: params
    }
    return await axios(obj);
  } catch (err) {
    // @ts-ignore
    Toast.fail(err.msg);
  }
}
// 生成订单
export const cancelOrders = async (params: any) => {
  try {
    let obj: RequestInterface = {
      url: "/api/shop/cancelOrder",
      method: "POST",
      data: params
    }
    return  await axios(obj);
  } catch (err) {
    // @ts-ignore
    Toast.fail(err.msg);
  }
}
// delele订单
export const deleteOrders = async (params: any) => {
  try {
    let obj: RequestInterface = {
      url: "/api/shop/deleteOrder",
      method: "POST",
      data: params
    }
    return await axios(obj);
  } catch (err) {
    // @ts-ignore
    Toast.fail(err.msg);
  }
}
// delele订单
export const orderDateils = async (params: any) => {
  try {
    let obj: RequestInterface = {
      url: "/api/shop/orderDateils",
      method: "GET",
      data: params
    }
    return  await axios(obj);
  } catch (err) {
    // @ts-ignore
    Toast.fail(err.msg);
  }
}
// 获取今日未完成的单量
export const getUndoneOrderNumber = async (params: any) => {
  try {
    let obj: RequestInterface = {
      url: "/api/hairstylist/getUndoneOrderNumber",
      method: "GET",
      data: params
    }
    return  await axios(obj);
  } catch (err) {
    // @ts-ignore
    Toast.fail(err.msg);
  }
}
export const reportAudit = async (params: any) => {
  try {
    let obj: RequestInterface = {
      url: "/api/root/reportAudit",
      method: "POST",
      data: params
    }
    return await axios(obj);
  } catch (err) {
    // @ts-ignore
    Toast.fail(err.msg);
  }
}